package com.bjpowernode.controller;

import com.bjpowernode.result.NameValueData;
import com.bjpowernode.result.Result;
import com.bjpowernode.result.SummaryData;
import com.bjpowernode.service.StatisticService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据统计
 */
@RestController
@RequiredArgsConstructor
public class StatisticController {

    private final StatisticService statisticService;

    @GetMapping("/api/summary/data")
    public Result summaryData() {
        SummaryData summaryData = statisticService.getSummaryData();
        return Result.OK(summaryData);
    }

    /**
     * 漏斗
     */
    @GetMapping("/api/sale/funnel")
    public Result saleFunnel() {
        List<NameValueData> nameValueDataList = statisticService.getSaleFunnel();

        return Result.OK(nameValueDataList);
    }

    /**
     * 饼图
     */
    @GetMapping("/api/clue/pie")
    public Result cluePie() {
        List<NameValueData> nameValueDataList = statisticService.getCluePie();

        return Result.OK(nameValueDataList);
    }
}
